package com.tms.basic.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tms.basic.pojo.domain.Position;
import com.tms.basic.service.PositionService;
import com.tms.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/position")
public class PositionController {
    
    @Autowired
    private PositionService positionService;
    
    @PostMapping("/listPosition")
    public R<Page<Position>> listPosition(Page<Position> page, Position position) {
        return R.success(positionService.listPositions(page, position));
    }
    
    @PostMapping("/addPosition")
    public R<Boolean> addPosition(@RequestBody Position position) {
        return R.success(positionService.createPosition(position));
    }
    
    @PostMapping("/updatePosition")
    public R<Boolean> updatePosition(@RequestBody Position position) {
        return R.success(positionService.updatePosition(position));
    }
    
    @PostMapping("/deletePosition/{id}")
    public R<Boolean> deletePosition(@PathVariable Long id) {
        return R.success(positionService.deletePosition(id));
    }
}